https://xkcd.com/1597/

Note: Thanks to http://happygitwithr.com for inspiration and material.

0.1 Definition/background

Git is a version control system that was created to help developers manage collaborative software projects. Git tracks the evolution of a set of files, called a repository or repo.

This helps us

0.2 Terminology

From https://help.github.com/articles/github-glossary/.

0.3 GitHub

There are many hosting services for remote repositories (GitHub, Bitbucket, GitLab, etc.). We will use GitHub in this class, but the ideas carry over to the other services.

By default, all materials on GitHub are public. This is good because you are getting your work out there and contributing to the open source community!

If you need private repos, checkout GitHub for Education - free private repos for students/postdocs/professors.

0.4 Creating Repos

Initialize readme (yes), .gitignore (R usually), license (e.g. GPL 3)

Your Turn

  1. Create a hello-world repo on https://github.com

Cloning a repo –

From scratch:

  1. Create the repo on the GitHub website

  2. Clone the repo

  3. Start working

  4. Add files, commit, push, etc.

From existing folder:

  1. Create the repo on the GitHub website

  2. Clone the repo

  3. Copy existing work into local folder

  4. Add files, commit, push, etc.

0.5 Pushing and pulling, a tug of war

Important: remember to pull before you start working to get the most up to date changes from your collaborators (or your past self) before making local changes!

0.6 When should I commit?

Think of commits as a checkpoint in a video game. This is a point in time when you want to save your status so that you can come back to it later if need be.

Commits are like voting. I like to do it early and often.

- Me, right now

0.7 Blow it up

Sometimes your local repo gets borked. That’s OK. There are ways that we can work really hard and fix them, but sometimes you just want to stash your files somewhere and re-clone from your centralized repository.

0.8 Git with RStudio

Rstudio (and our class RStudio server) allows you to make projects based on GitHub repos.

Local RStudio works much the same way, with the ability to push/pull from a local project to a GitHub repo.

By letting us

  1. Select files to commit.
  2. Commit
  3. Push/Pull

0.9 Collaboration

In this class, we will have a collaborative project. It will be hosted on GitHub and part of your grade will be how well you collaborate through the use of GitHub. For this, we will need to have project repos that everyone can push to!

GitHub Repo site (https://github.com/username/reponame) > Settings > Collaborators & Teams > Collaborators > Add collaborator

Your collaborators will have a lot of power in your repo, so choose wisely! They can change anything in the repo and add their own files. They can also delete your files! The only thing they can’t do is delete the repo, add collaborators, or change other settings for the repo.

0.10 Installation help

We are not covering installation on your personal computers for this class. If you would like to work through it on your own, here is an excellent guide: http://happygitwithr.com/installation-pain.html

Feel free to come to office hours or setup individual time with us if you need help.

Your Turn

  1. Edit the README file in your hello-world repo

  2. Commit and push changes

  3. Check out your commit history!

  4. Add me (andeek) as a collaborator to your hello-world repo